<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>这次是新增API 这2个测试都失败了！！！</title>
</head>
<body>
    <h4>监听网络状态</h4>
    <script type="text/javascript">
        window.addEventListener('online' , function () {
            alert("网络链接已建立")
        });
        window.addEventListener('offline',function () {
            alert("网络链接已断开")
        });
    </script>
    <h4>定位功能demo</h4>
    <script type="text/javascript">
        if (navigator.geolocation){
            navigator.geolocation.getCurrentPosition(successCallback , errorCallback);
        }else {
            alert("您的浏览器不支持定位")
        }
        function successCallback(position) {
            var lon = position.coords.longitude;
            var lat = position.coords.latitude;
            alert("经度：" + lon +",纬度：" + lat);
        }
        function errorCallback(error) {
            alert("获取用户位置失败")
        }
    </script>
</body>
</html>